export default function(fn) {
  return (obj = {}) => {
    return new Promise((resolve, reject) => {
      obj.success = res => {
        resolve(res)
      }
      obj.fail = err => {
        reject(err)
      }
      fn(obj)
    })
  }
}
